#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int a[10000], b[10000], c[20000];
int main()
{
	int i, j, k, p1 = 0, p2 = 0;

	for (i = 0;; i++)
	{
		scanf("%d", &a[i]);
		if (a[i] == 0)
			break;
	}

	for (j = 0;; j++)
	{
		scanf("%d", &b[j]);
		if (b[j] == 0)
			break;
	}

	for (k = 0; k < i + j; k++)
	{
		if (p1 == i)
			c[k] = b[p2++];
		else if (p2 == j)
			c[k] = a[p1++];
		else if (a[p1] < b[p2])
			c[k] = a[p1++];
		else
			c[k] = b[p2++];
	}

	for (k = 0; k < i + j; k++)
	{
		if (k != i + j - 1)
		{
			if (c[k] != c[k + 1])
				printf("%d ", c[k]);
		}
		else
			printf("%d", c[k]);
	}
	return 0;
}